import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { WxPersonalChannelService } from './wx-personal-channel.service';
import { PersonalChannelService } from '../../pc/personal-channel/personal-channel.service';
import { ApiTags } from '@nestjs/swagger/dist/decorators';
import { LockChannelDto } from './dto/lock-channel-dto'
import { RecudePhoneCountDto } from '../wxuser/dto/recude-phone-count-dto';

@ApiTags('小程序个人车源')
@Controller('wxpersonalchannel')
export class WxPersonalChannelController {
  constructor(private readonly wxPersonalChannelService: WxPersonalChannelService, 
    private readonly personalChannelService: PersonalChannelService ) {}

  @Get('page')
  async findPage(@Query() query: any) {
    return await this.personalChannelService.findPage(query)
  }

  @Get()
  async findOne(@Query() query: { id: string }) {
    return await this.personalChannelService.findOne(query.id)
  }  

  @Get('new')
  async findNew() {
    return await this.wxPersonalChannelService.findNew()
  }

  @Post('lock')
  async lockChannel(@Body() dto: LockChannelDto) {
    console.log(dto);
    return await this.wxPersonalChannelService.lockChannel(dto);
  }

  @Get('expire/:id')
  async checkChannelLockExpire(@Param('id') id: string) {
    return await this.wxPersonalChannelService.checkChannelLockExpire(id)
  }

  @Get('checkOut/:id')
  async checkOuted(@Param('id') id: string) {
    return await this.wxPersonalChannelService.checkOuted(id)
  }
}
